using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace xna_game_engine.source
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class Enemy : Entity
    {
        // functions
        #region Functions
        public Enemy(string name, Vector2 pos) : base(name)
        {
            mAnim = new CAnimation(6, 32, 32, 2);
            mDirection = Vector2.Zero;
            mIsMoving = true;
            mPosition = pos;
            mVelocity = new Vector2(0.0f, 0.0f);
            mHealthTickRegen = 2.0f;
            mManaTickRegen = 2.0f;
            mHealthTickTimer = new TongaTimer(mHealthTickRegen);
            mManaTickTimer = new TongaTimer(mManaTickRegen);
            mHealthBar = new StatusBar(new Vector2(0.2f, 0.2f), Color.Red, Color.Green);
            mXpWorth = 10;
            mCurGold = (double)GameGlobals.RNG.Next(1, 5);
        }

        public override void Initialize()
        {
            // Modify our stats
            // Setup our stats...
            mStats["Strength"] = 10;
            mStats["Intellect"] = 10;
            mStats["Agility"] = 10;
            mStats["Stamina"] = 10;
            mStats["Vim"] = 10;

            // Calc our stats
            mMaxHP = mCurHP = 5 * mStats["Stamina"];
        }

        public override void LoadContent(ContentManager cm)
        {
            mTexture = cm.Load<Texture2D>("sprites\\enemy");
            mAnimTexture = cm.Load<Texture2D>("sprites\\enemy_anim");
            mHealthBar.LoadContent();
            mTextFont = cm.Load<SpriteFont>("fonts\\test_font");

            // Setup bounding box
            mBoundingBox.Max = new Vector3(mPosition.X + mTexture.Width, mPosition.Y + mTexture.Height, 0);
            mBoundingBox.Min = new Vector3(mPosition.X, mPosition.Y, 0);
        }

        public override void Draw()
        {
            if (!mIsDead)
            {
                GameSystems.Graphics.DrawAnimation(mAnim, AnimTexture, mPosition, Color.White);
                mHealthBar.Draw(mPosition + new Vector2(-10.0f, -10.0f));
            }
        }

        public override void EquipItem(BaseItem item, EQUIPMENT_SLOTS slot)
        {
            //item
        }

        public override void LevelUp(int level)
        {

        }

        // Other functions
        public void Update(GameTime gt)
        {
            // Recalc our stats
            mMaxHP = 5 * mStats["Stamina"];
            BaseUpdate(gt);
        }
        #endregion Functions

        #region Properties
        #endregion
    }
}